<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>lhx个人博客</title><meta name="keywords" content="前端基础CSS、Js、Vue、React、移动端、小程序、网络"><meta name="author" content="李汉鑫"><meta name="copyright" content="李汉鑫"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="前端基础CSS、Js、Vue、React、移动端、小程序、网络">
<meta property="og:type" content="website">
<meta property="og:title" content="lhx个人博客">
<meta property="og:url" content="http://example.com/index.html">
<meta property="og:site_name" content="lhx个人博客">
<meta property="og:description" content="前端基础CSS、Js、Vue、React、移动端、小程序、网络">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img2.baidu.com/it/u=203845187,735199026&fm=26&fmt=auto&gp=0.jpg">
<meta property="article:author" content="李汉鑫">
<meta property="article:tag" content="前端基础CSS、Js、Vue、React、移动端、小程序、网络">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://img2.baidu.com/it/u=203845187,735199026&fm=26&fmt=auto&gp=0.jpg"><link rel="shortcut icon" href="https://img2.baidu.com/it/u=1328275982,1207856622&fm=26&fmt=auto&gp=0.jpg"><link rel="canonical" href="http://example.com/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'lhx个人博客',
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2021-09-01 22:26:54'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="lhx个人博客" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://img2.baidu.com/it/u=203845187,735199026&amp;fm=26&amp;fmt=auto&amp;gp=0.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">31</div></a></div><div class="data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a></div><div class="data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">10</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">lhx个人博客</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">lhx个人博客</h1><div id="site-subtitle"><span id="subtitle"></span></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left_radius"><a href="/%E7%A7%BB%E5%8A%A8%E7%AB%AF/%E7%A7%BB%E5%8A%A8%E7%AB%AF/" title="移动端">     <img class="post_bg" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="移动端"></a></div><div class="recent-post-info"><a class="article-title" href="/%E7%A7%BB%E5%8A%A8%E7%AB%AF/%E7%A7%BB%E5%8A%A8%E7%AB%AF/" title="移动端">移动端</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-06-07T09:21:39.000Z" title="发表于 2021-06-07 17:21:39">2021-06-07</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/">移动端</a></span></div><div class="content">移动端开发相关概念​        在学习移动端之前，我们先来学习一些基础的概念和专有名词，这些知识会在以后的面试、工作沟通中经常用到。
屏幕相关1.屏幕大小​            屏幕大小是指屏幕的对角线长度，单位一般是英寸(inch)。常见的手机屏幕大小有： 3.5寸、4寸、4.7寸、5.0寸、5.5寸、6.0寸等等，英寸与厘米的换算关系为 ：**1英寸(inch) = 2.54厘米(cm)**

2.屏幕分辨率​            屏幕分辨率是指屏幕在：横向、纵向上所拥有的物理像素点总数。一般表示用 n * m 表示。
​            例如： IPhone 6 的屏幕分辨率为 750 * 1334 

​    注意点:    
屏幕分辨率是一个固定值，屏幕生产出来就确定了，无法修改！！
屏幕分辨率、显示分辨率是两个概念，电脑或手机的设置中可以修改的是：显示分辨率。
显示分辨率指的是设备当前所用到的物理像素点数，或者说：屏幕分辨率 &gt;= 显示分辨率。



常见手机分辨率



型号
分辨率（物理像素点总和）



IPhone 3G / 3GS
320 * ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%B0%8F%E7%A8%8B%E5%BA%8F/" title="小程序基础">     <img class="post_bg" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="小程序基础"></a></div><div class="recent-post-info"><a class="article-title" href="/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%B0%8F%E7%A8%8B%E5%BA%8F/" title="小程序基础">小程序基础</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-05-03T05:20:10.000Z" title="发表于 2021-05-03 13:20:10">2021-05-03</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E5%B0%8F%E7%A8%8B%E5%BA%8F/">小程序</a></span></div><div class="content">数据绑定
C(创建数据)

Vue
在组件配置对象中,具有data工厂函数,可以返回出data对象
面试题:为什么data必须是一个函数
如果data是一个对象,那么通过当前组件构造函数创建的多个组件实例,会共享这一个data对象,导致多组件没有各自的独立状态




React
在class组件中,class结构中具有state属性,属性值为一个对象


小程序
在组件配置对象中,具有data对象
注意:小程序会将data对象进行JSON化,实现对象深克隆,所以不需要像Vue一样
小程序的data属性可以后续直接通过setData新增,没有任何区别




R(读取数据)

在模版中渲染
Vue
在template中使用插值语法,将data中的属性名写入内部即可使用
注意:在template中,想要把data中的数据作为文本内容显示出来,才需要使用插值语法


React
在render函数的return中.使用{},大括号中书写this.state.msg即可


小程序
与Vue相同
注意:只要想在wxml中使用data中的数据,一定要加插值语法




在js代码中读取数据
V ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/%E7%BD%91%E7%BB%9C/http%E5%8D%8F%E8%AE%AE%E4%B8%89%E6%AC%A1%E6%8F%A1%E6%89%8B%E5%92%8C%E5%9B%9B%E6%AC%A1%E6%8C%A5%E6%89%8B/" title="http协议三次握手和四次挥手">     <img class="post_bg" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="http协议三次握手和四次挥手"></a></div><div class="recent-post-info"><a class="article-title" href="/%E7%BD%91%E7%BB%9C/http%E5%8D%8F%E8%AE%AE%E4%B8%89%E6%AC%A1%E6%8F%A1%E6%89%8B%E5%92%8C%E5%9B%9B%E6%AC%A1%E6%8C%A5%E6%89%8B/" title="http协议三次握手和四次挥手">http协议三次握手和四次挥手</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-10-25T13:40:49.000Z" title="发表于 2020-10-25 21:40:49">2020-10-25</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%BD%91%E7%BB%9C/">网络</a></span></div><div class="content">什么是TCP三次握手？TCP是一种面向连接的单播协议，在发送数据前，通信双方必须在彼此间建立一条连接。所谓的“连接”，其实是客户端和服务器的内存里保存的一份关于对方的信息，如ip地址、端口号等。
所谓三次握手(Three-way Handshake)，是指建立一个TCP连接时，需要客户端和服务器总共发送3个数据包

ACK：确认有效，确认序号。 SYN：发起一个新连接。

你招手
妹子点头微笑并招手
你点头微笑

为什么要三次握手？客户端和服务端通信前要进行连接，“3次握手”的作用就是双方都能明确自己和对方的收、发能力是正常的。
第一次握手：客户端发送网络包，服务端收到了。这样服务端就能得出结论：客户端的发送能力、服务端的接收能力是正常的。
第二次握手：服务端发包，客户端收到了。这样客户端就能得出结论：服务端的接收、发送能力，客户端的接收、发送能力是正常的。 从客户端的视角来看，我接到了服务端发送过来的响应数据包，说明服务端接收到了我在第一次握手时发送的网络包，并且成功发送了响应数据包，这就说明，服务端的接收、发送能力正常。而另一方面，我收到了服务端的响应数据包，说明我第一次发送的网络 ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/%E7%BD%91%E7%BB%9C/%E5%9C%A8%E6%B5%8F%E8%A7%88%E5%99%A8%E5%9C%B0%E5%9D%80%E6%A0%8F%E8%BE%93%E5%85%A5url%E7%84%B6%E5%90%8E%E6%95%B2%E5%87%BB%E5%9B%9E%E8%BD%A6%E4%B9%8B%E5%90%8E%E9%83%BD%E5%81%9A%E4%BA%86%E4%BB%80%E4%B9%88/" title="在浏览器地址栏输入url然后敲击回车之后都做了什么">     <img class="post_bg" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="在浏览器地址栏输入url然后敲击回车之后都做了什么"></a></div><div class="recent-post-info"><a class="article-title" href="/%E7%BD%91%E7%BB%9C/%E5%9C%A8%E6%B5%8F%E8%A7%88%E5%99%A8%E5%9C%B0%E5%9D%80%E6%A0%8F%E8%BE%93%E5%85%A5url%E7%84%B6%E5%90%8E%E6%95%B2%E5%87%BB%E5%9B%9E%E8%BD%A6%E4%B9%8B%E5%90%8E%E9%83%BD%E5%81%9A%E4%BA%86%E4%BB%80%E4%B9%88/" title="在浏览器地址栏输入url然后敲击回车之后都做了什么">在浏览器地址栏输入url然后敲击回车之后都做了什么</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-10-24T14:10:19.000Z" title="发表于 2020-10-24 22:10:19">2020-10-24</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%BD%91%E7%BB%9C/">网络</a></span></div><div class="content">从url输入地址到最终网页渲染，中间发生了什么？
DNS查询 / 解析


将域名地址解析成ip地址
浏览器DNS缓存
计算机DNS缓存
路由器DNS缓存
网络运营商DNS缓存




TCP连接： TCP三次握手


第一次握手：浏览器发送给服务器，告诉服务器我准备好了，将要发送请求

第二次握手：服务器发送给浏览器，告诉浏览器我也准备好了，需要和你再次确认一下 

第三次握手：浏览器发送给服务器，告诉服务器确认完毕，马上发送请求 

Connection: keep-alive 保持长连接（保持TCP连接）




发送请求
按照HTTP协议的规定，生成请求报文，浏览器将请求报文发送给服务器
浏览器将请求报文发送给服务器

返回响应
按照HTTP协议的规定，生成相应报文，服务器将请求报文发送给客户端

渲染页面：

断开连接：TCP四次挥手
第一次挥手：浏览器发送给服务器，告诉服务器请求报文发送完毕
第二次挥手：服务器发送给浏览器，告诉浏览器请求报文接受完毕，可以等待断开
第三次挥手：服务器发送给浏览器，告诉浏览器响应报文发送完毕
第四次挥手：浏览器发送给服务器，告诉服务器响应报文 ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/%E7%BD%91%E7%BB%9C/%E8%AF%B7%E6%B1%82%E5%93%8D%E5%BA%94%E6%8A%A5%E6%96%87/" title="请求响应报文">     <img class="post_bg" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="请求响应报文"></a></div><div class="recent-post-info"><a class="article-title" href="/%E7%BD%91%E7%BB%9C/%E8%AF%B7%E6%B1%82%E5%93%8D%E5%BA%94%E6%8A%A5%E6%96%87/" title="请求响应报文">请求响应报文</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-10-24T12:21:39.000Z" title="发表于 2020-10-24 20:21:39">2020-10-24</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%BD%91%E7%BB%9C/">网络</a></span></div><div class="content">GET请求报文123456789101112131415161718192021222324252627282930311)GET http://localhost:3000/hello.html HTTP/1.1：GET请求，请求服务器路径为 http://localhost:3000/hello.html，?后面跟着的是请求参数（查询字符串），协议是HTTP 1.1版本2)Host: localhost:3000：请求的主机名为localhost，端口号30003)Connection: keep-alive：处理完这次请求后继续保持连接，默认为3000ms4)Pragma: no-cache：不缓存该资源，http 1.0的规定5)Cache-Control: no-cache： 不缓存该资源 http 1.1的规定，优先级更高6)Upgrade-Insecure-Requests: 1：告诉服务器，支持发请求的时候不用http而用https7)User-Agent: Mozilla/5.0 (...：与浏览器和OS相关的信息。有些网站会显示用户的系统版本和浏览器版本信息，这都是 ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/%E5%B7%A5%E7%A8%8B%E5%8C%96/Webpack/" title="Webpack">     <img class="post_bg" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Webpack"></a></div><div class="recent-post-info"><a class="article-title" href="/%E5%B7%A5%E7%A8%8B%E5%8C%96/Webpack/" title="Webpack">Webpack</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-10-23T12:38:19.000Z" title="发表于 2020-10-23 20:38:19">2020-10-23</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E5%B7%A5%E7%A8%8B%E5%8C%96/">工程化</a></span></div><div class="content">webpack 快速入门教程1、了解 Webpack 相关
什么是 webpack


Webpack 是一个模块打包器(bundler)。
在 Webpack 看来, 前端的所有资源文件(js/json/css/img/less/…)都会作为模块处理
它将根据模块的依赖关系进行静态分析，生成对应的静态资源


五大“护法”


Entry：入口起点(entry point)指示 webpack 应该使用哪个模块，来作为构建其内部依赖图的开始。
Output：output 属性告诉 webpack 在哪里输出它所创建的 bundles，以及如何命名这些文件，默认值为 ./dist。
Loader：loader 让 webpack 能够去处理那些非 JavaScript 文件（webpack 自身只能解析 JavaScript）。
Plugins：插件则可以用于执行范围更广的任务。插件的范围包括，从打包优化和压缩，一直到重新定义环境中的变量等。
Mode：模式，有生产模式 production 和开发模式 development


理解 Loader


Webpack 本身只能加载  ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/React/%E8%99%9A%E6%8B%9Fdom%E5%92%8Cdiff%E7%AE%97%E6%B3%95/" title="虚拟dom和diff算法">     <img class="post_bg" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="虚拟dom和diff算法"></a></div><div class="recent-post-info"><a class="article-title" href="/React/%E8%99%9A%E6%8B%9Fdom%E5%92%8Cdiff%E7%AE%97%E6%B3%95/" title="虚拟dom和diff算法">虚拟dom和diff算法</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-08-29T14:36:53.000Z" title="发表于 2020-08-29 22:36:53">2020-08-29</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/React/">React</a></span></div><div class="content">虚拟DOM的diff算法什么是虚拟domreact元素就是一个虚拟dom
小结: 
直接操作dom元素,效率远远低于操作数据(虚拟dom)
react中创建出来的元素,其实不是真实的dom元素,是虚拟dom
react如何渲染视图层: 根据之前的结构,生成一个旧的虚拟dom. 然后代码发生变化,也就意味着新的虚拟dom结构发生变化.这个时候react底层会比较这两个虚拟dom结构.然后根据比较的结构,修改真实的dom.真实dom被修改了,视图就会跟着发生变化
什么是diff算法一种对比新/旧虚拟DOM树的高效算法，能快速计算哪些虚拟DOM树发生了变化，从而只更新局部DOM。
传统的 diff 算法性能开销大，无法满足大规模 DOM 操作需求。 React 通过制定大胆的策略，将性能开销降到最低。
diff 策略
Web UI 中 DOM 节点跨层级的移动操作特别少，可以忽略不计。
拥有相同类的两个组件将会生成相似的树形结构，`拥有不同类的两个组件将会生成不同的树形结构。
对于同一层级的一组子节点，它们可以通过唯一 id 进行区分。

基于以上三个前提策略，React 分别对 tree  ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/Nodejs/mongoose%E7%9A%84CRUD%E6%96%B9%E6%B3%95%E6%80%BB%E7%BB%93/" title="mongoose的CRUD方法总结">     <img class="post_bg" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="mongoose的CRUD方法总结"></a></div><div class="recent-post-info"><a class="article-title" href="/Nodejs/mongoose%E7%9A%84CRUD%E6%96%B9%E6%B3%95%E6%80%BB%E7%BB%93/" title="mongoose的CRUD方法总结">mongoose的CRUD方法总结</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-08-29T10:08:10.000Z" title="发表于 2020-08-29 18:08:10">2020-08-29</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/node-js/">node.js</a></span></div><div class="content">Schema
12345678910111213141516171819202122232425262728293031323334let studentsSchema = new Schema(&#123;      stu_id:&#123;        type:String,//字段类型        required:true,//必填字段        unique:true//唯一（不可重复）字段      &#125;,      stu_name:&#123;        type:String,        required:true,//必填字段      &#125;,      stu_age:&#123;        type:Number,        required:true,//必填字段      &#125;,      stu_sex:&#123;        type:String,        required:true,//必填字段        default:&#x27;男&#x27;      &#125;,       ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/Nodejs/MongoDB%E5%8E%9F%E7%94%9FCRUD%E5%91%BD%E4%BB%A4%E6%80%BB%E7%BB%93/" title="MongoDB原生CRUD命令总结">     <img class="post_bg" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MongoDB原生CRUD命令总结"></a></div><div class="recent-post-info"><a class="article-title" href="/Nodejs/MongoDB%E5%8E%9F%E7%94%9FCRUD%E5%91%BD%E4%BB%A4%E6%80%BB%E7%BB%93/" title="MongoDB原生CRUD命令总结">MongoDB原生CRUD命令总结</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-08-21T13:18:07.000Z" title="发表于 2020-08-21 21:18:07">2020-08-21</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/node-js/">node.js</a></span></div><div class="content">MongoDB原生CRUD（增删改查）命令总结-C creat：
db.集合名.insert(文档对象)
db.集合名.insertOne(文档对象)
db.集合名.insertMany([文档对象，文档对象])

-R read：
db.集合名.find(查询条件[,投影])
    举例:db.students.find(&#123;age:18&#125;),查找年龄为18的所有信息
    举例:db.students.find(&#123;age:18,name:&#39;jack&#39;&#125;),查找年龄为18且名字为jack的学生
    
常用操作符：
    1. &lt; , &lt;= , &gt; , &gt;= , !==   对应为： $lt(less than) $lte(less than eq) $gt(great than) $gte $ne(not eq)   
        举例：db.集合名.find(&#123;age:&#123;$gte:20&#125;&#125;),年龄是大于等于20的
    2.逻辑或：使用$in 或 $ ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/%E5%B7%A5%E7%A8%8B%E5%8C%96/Gulp/" title="Gulp">     <img class="post_bg" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Gulp"></a></div><div class="recent-post-info"><a class="article-title" href="/%E5%B7%A5%E7%A8%8B%E5%8C%96/Gulp/" title="Gulp">Gulp</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-08-20T13:11:09.000Z" title="发表于 2020-08-20 21:11:09">2020-08-20</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E5%B7%A5%E7%A8%8B%E5%8C%96/">工程化</a></span></div><div class="content">Gulp介绍
中文主页: http://www.gulpjs.com.cn/
gulp是与webpack功能类似的前端项目构建工具, 也是基于Nodejs的自动任务运行器
能自动化地完成 javascript/coffee/sass/less/html/image/css 等文件的合并、压缩、检查、监听文件变化、浏览器自动刷新、测试等任务
gulp更高效(异步多任务), 更易于使用, 插件高质量

使用步骤：
安装 nodejs, 查看版本: node -v,务必保证node是6以上的版本。
创建一个简单的应用gulp_test，文件结构如下：12345678910111213|- dist|- build|- src  |- js  |- less  |- css  |- index.html|- gulpfile.js-----gulp配置文件|- package.json  &#123;    &quot;name&quot;: &quot;gulp_test&quot;,    &quot;version&quot;: &quot;1.0.0&quot;  &#125; 
全局 ...</div></div></div><nav id="pagination"><div class="pagination"><span class="page-number current">1</span><a class="page-number" href="/page/2/#content-inner">2</a><span class="space">&hellip;</span><a class="page-number" href="/page/4/#content-inner">4</a><a class="extend next" rel="next" href="/page/2/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://img2.baidu.com/it/u=203845187,735199026&amp;fm=26&amp;fmt=auto&amp;gp=0.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">李汉鑫</div><div class="author-info__description">前端基础CSS、Js、Vue、React、移动端、小程序、网络</div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">31</div></a></div><div class="card-info-data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a></div><div class="card-info-data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">10</div></a></div></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">个人网站,欢迎交流</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/%E7%A7%BB%E5%8A%A8%E7%AB%AF/%E7%A7%BB%E5%8A%A8%E7%AB%AF/" title="移动端"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="移动端"/></a><div class="content"><a class="title" href="/%E7%A7%BB%E5%8A%A8%E7%AB%AF/%E7%A7%BB%E5%8A%A8%E7%AB%AF/" title="移动端">移动端</a><time datetime="2021-06-07T09:21:39.000Z" title="发表于 2021-06-07 17:21:39">2021-06-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%B0%8F%E7%A8%8B%E5%BA%8F/" title="小程序基础"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="小程序基础"/></a><div class="content"><a class="title" href="/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%B0%8F%E7%A8%8B%E5%BA%8F/" title="小程序基础">小程序基础</a><time datetime="2021-05-03T05:20:10.000Z" title="发表于 2021-05-03 13:20:10">2021-05-03</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/%E7%BD%91%E7%BB%9C/http%E5%8D%8F%E8%AE%AE%E4%B8%89%E6%AC%A1%E6%8F%A1%E6%89%8B%E5%92%8C%E5%9B%9B%E6%AC%A1%E6%8C%A5%E6%89%8B/" title="http协议三次握手和四次挥手"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="http协议三次握手和四次挥手"/></a><div class="content"><a class="title" href="/%E7%BD%91%E7%BB%9C/http%E5%8D%8F%E8%AE%AE%E4%B8%89%E6%AC%A1%E6%8F%A1%E6%89%8B%E5%92%8C%E5%9B%9B%E6%AC%A1%E6%8C%A5%E6%89%8B/" title="http协议三次握手和四次挥手">http协议三次握手和四次挥手</a><time datetime="2020-10-25T13:40:49.000Z" title="发表于 2020-10-25 21:40:49">2020-10-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/%E7%BD%91%E7%BB%9C/%E5%9C%A8%E6%B5%8F%E8%A7%88%E5%99%A8%E5%9C%B0%E5%9D%80%E6%A0%8F%E8%BE%93%E5%85%A5url%E7%84%B6%E5%90%8E%E6%95%B2%E5%87%BB%E5%9B%9E%E8%BD%A6%E4%B9%8B%E5%90%8E%E9%83%BD%E5%81%9A%E4%BA%86%E4%BB%80%E4%B9%88/" title="在浏览器地址栏输入url然后敲击回车之后都做了什么"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="在浏览器地址栏输入url然后敲击回车之后都做了什么"/></a><div class="content"><a class="title" href="/%E7%BD%91%E7%BB%9C/%E5%9C%A8%E6%B5%8F%E8%A7%88%E5%99%A8%E5%9C%B0%E5%9D%80%E6%A0%8F%E8%BE%93%E5%85%A5url%E7%84%B6%E5%90%8E%E6%95%B2%E5%87%BB%E5%9B%9E%E8%BD%A6%E4%B9%8B%E5%90%8E%E9%83%BD%E5%81%9A%E4%BA%86%E4%BB%80%E4%B9%88/" title="在浏览器地址栏输入url然后敲击回车之后都做了什么">在浏览器地址栏输入url然后敲击回车之后都做了什么</a><time datetime="2020-10-24T14:10:19.000Z" title="发表于 2020-10-24 22:10:19">2020-10-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/%E7%BD%91%E7%BB%9C/%E8%AF%B7%E6%B1%82%E5%93%8D%E5%BA%94%E6%8A%A5%E6%96%87/" title="请求响应报文"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="请求响应报文"/></a><div class="content"><a class="title" href="/%E7%BD%91%E7%BB%9C/%E8%AF%B7%E6%B1%82%E5%93%8D%E5%BA%94%E6%8A%A5%E6%96%87/" title="请求响应报文">请求响应报文</a><time datetime="2020-10-24T12:21:39.000Z" title="发表于 2020-10-24 20:21:39">2020-10-24</time></div></div></div></div><div class="card-widget card-categories"><div class="item-headline">
            <i class="fas fa-folder-open"></i>
            <span>分类</span>
            <a class="card-more-btn" href="/categories/" title="查看更多">
    <i class="fas fa-angle-right"></i></a>
            </div>
            <ul class="card-category-list" id="aside-cat-list">
            <li class="card-category-list-item "><a class="card-category-list-link" href="/categories/CSS/"><span class="card-category-list-name">CSS</span><span class="card-category-list-count">3</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/JavaScript/"><span class="card-category-list-name">JavaScript</span><span class="card-category-list-count">3</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/React/"><span class="card-category-list-name">React</span><span class="card-category-list-count">5</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Vue/"><span class="card-category-list-name">Vue</span><span class="card-category-list-count">9</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/node-js/"><span class="card-category-list-name">node.js</span><span class="card-category-list-count">2</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/%E4%BB%A3%E7%A0%81%E7%AE%A1%E7%90%86/"><span class="card-category-list-name">代码管理</span><span class="card-category-list-count">2</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/%E5%B0%8F%E7%A8%8B%E5%BA%8F/"><span class="card-category-list-name">小程序</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/%E5%B7%A5%E7%A8%8B%E5%8C%96/"><span class="card-category-list-name">工程化</span><span class="card-category-list-count">2</span></a></li>
            </ul></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>归档</span><a class="card-more-btn" href="/archives/" title="查看更多">
    <i class="fas fa-angle-right"></i></a></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/06/"><span class="card-archive-list-date">六月 2021</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/05/"><span class="card-archive-list-date">五月 2021</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2020/10/"><span class="card-archive-list-date">十月 2020</span><span class="card-archive-list-count">4</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2020/08/"><span class="card-archive-list-date">八月 2020</span><span class="card-archive-list-count">5</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2020/07/"><span class="card-archive-list-date">七月 2020</span><span class="card-archive-list-count">3</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2019/07/"><span class="card-archive-list-date">七月 2019</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2018/07/"><span class="card-archive-list-date">七月 2018</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2018/04/"><span class="card-archive-list-date">四月 2018</span><span class="card-archive-list-count">4</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">31</div></div><div class="webinfo-item"><div class="item-name">本站访客数 :</div><div class="item-count" id="busuanzi_value_site_uv"></div></div><div class="webinfo-item"><div class="item-name">本站总访问量 :</div><div class="item-count" id="busuanzi_value_site_pv"></div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2021-09-01T14:26:54.036Z"></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By 李汉鑫</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>function subtitleType () {
  if (false) { 
    window.typed = new Typed("#subtitle", {
      strings: ["世界上只有一种真正的英雄主义，那就是在认清生活的真相后依然热爱生活"],
      startDelay: 300,
      typeSpeed: 150,
      loop: true,
      backSpeed: 50
    })
  } else {
    document.getElementById("subtitle").innerHTML = '世界上只有一种真正的英雄主义，那就是在认清生活的真相后依然热爱生活'
  }
}

if (false) {
  if (typeof Typed === 'function') {
    subtitleType()
  } else {
    getScript('https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js').then(subtitleType)
  }
} else {
  subtitleType()
}</script></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>